﻿using System;
using System.Collections.Generic;
using System.Linq;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Documents;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;

// The Templated Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234235

namespace Centny
{
    public sealed class FlipImgView : FlipView
    {
        public FlipImgView()
        {
            this.Items.VectorChanged += OnVectorChanged;
        }
        void OnVectorChanged(IObservableVector<Object> sender, IVectorChangedEventArgs @event)
        {
            this.SetValue(ItemsCountProperty, this.Items.Count);
        }
        public static readonly DependencyProperty ItemsCountProperty = DependencyProperty.Register("ItemsCount", typeof(int), typeof(FlipImgView), new PropertyMetadata(0));
        public int ItemsCount
        {
            get { return (int)this.GetValue(ItemsCountProperty); }
        }
    }
    public class IndexTotalConverter : DependencyObject, IValueConverter
    {

        public static readonly DependencyProperty ItemsCountProperty = DependencyProperty.Register("ItemsCount", typeof(int), typeof(IndexTotalConverter), new PropertyMetadata(0));
        public int ItemsCount
        {
            get { return (int)this.GetValue(ItemsCountProperty); }
            set { this.SetValue(ItemsCountProperty, value); }
        }

        public object Convert(object value, Type targetType,
                              object parameter, string culture)
        {
            if (value == null)
            {
                return null;
            }
            return ((int)value + 1) + "/" + this.ItemsCount;
        }

        public object ConvertBack(object value, Type targetType,
                                  object parameter, string culture)
        {
            throw new NotImplementedException();
        }
    }
}
